﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class TechnologyNgRecipeConfig : POBaseConfig<TechnologyNgRecipePO>
    {
        public override void InitializeData(EntityTypeBuilder<TechnologyNgRecipePO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<TechnologyNgRecipePO> builder, ref int index)
        {
            builder.HasComment("工艺NG配置表");
            builder.Property(entity => entity.TechnologyRouteProcessId).ConfigColumn("TECHNOLOGY_ROUTE_PROCESS_ID", "工艺路径工序ID").HasColumnOrder(index++);
            builder.Property(entity => entity.Step).ConfigColumn("STEP", "工步").HasColumnOrder(index++);
            builder.Property(entity => entity.ParamCode).ConfigColumn("PARAM_CODE", "参数编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.LowerLimit).ConfigColumn("LOWER_LIMIT", "下限值").HasColumnOrder(index++);
            builder.Property(entity => entity.IsLowerLimitContained).ConfigColumn("IS_LOWER_LIMIT_CONTAINED", "是否包含下限值").HasColumnOrder(index++);
            builder.Property(entity => entity.UpperLimit).ConfigColumn("UPPER_LIMIT", "上限值").HasColumnOrder(index++);
            builder.Property(entity => entity.IsUpperLimitContained).ConfigColumn("IS_UPPER_LIMIT_CONTAINED", "是否包含上限值 ").HasColumnOrder(index++);
            builder.Property(entity => entity.NgCode).ConfigColumn("NG_CODE", "NG编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<TechnologyNgRecipePO> builder)
        {
            builder.HasIndex(entity => new { entity.TechnologyRouteProcessId, entity.Step, entity.ParamCode, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1");
        }
    }
}
